package com.cuntian.controller;

import com.cuntian.rocketmq.producer.RocketMQProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 35371
 */
@RestController
@Slf4j
@RequestMapping("rocketmq")
public class RocketmqSendMsg {

    private final RocketMQProducer rocketMQProducer;

    public RocketmqSendMsg(RocketMQProducer rocketMQProducer) {
        this.rocketMQProducer = rocketMQProducer;
    }

    @GetMapping("/hello")
    public String hello(){
        return "welcome to rocketmq demo";
    }

    @GetMapping("/msgWithValue")
    public void sendMsgWithValue(String value){
        log.info("参数 value:{}",value);
        rocketMQProducer.sendMessageWithValue(value);
    }

    @GetMapping("/msgWithKey")
    public void sendMessageWithKey(String key,String value){
        log.info("参数 key:{},value:{}",key,value);
        rocketMQProducer.sendMessageWithKey(key,value);
    }

    @GetMapping("/msgWithTag")
    public void sendMessageWithTag(String tag,String value){
        log.info("参数 tag:{},value:{}",tag,value);
        rocketMQProducer.sendMessageWithTag(tag,value);
    }

    @GetMapping("/msgWithAll")
    public void sendMessageWithAll(String key,String tag,String value){
        log.info("参数 key:{},tag:{},value:{}",key,tag,value);
        rocketMQProducer.sendMessageWithAll(key,tag,value);
    }


}
